class Solution3 {
    public int removeDuplicates(int[] nums) {
        int n = nums.length;
        //特殊条件
        if(n <= 2){
            return n;
        }
        //定义快慢双指针
        int slow = 2,fast = 2;
        while(fast < n){
            if(nums[slow - 2] != nums[fast]){
                nums[slow] = nums[fast];
                ++slow;
            }
            ++fast;
        }
        return slow;
    }
}